<?php
namespace app\common\controller;
use app\common\model\Permission;
use app\common\model\RolePermissionRelation;
use app\common\model\UserRoleRelation;
use think\Controller;
use think\facade\Cookie;
use think\facade\Request;
use think\facade\Session;
class Base extends Controller{
    /**获取值
     * 1  session   2  cooken
     * @param int $type
     * @return bool|mixed
     */
    protected function getUserInfo($type = 1)
    {
        if ($type === 1) {
            $userinfo = Session::get('userinfo');
            if (empty($userinfo) || $userinfo['expire_time'] < time()) {
                $userinfo = false;
            }
            return $userinfo;
        } else {
            $userinfo = Cookie::get('userinfo');
            $userinfo = json_decode($userinfo, true);
            if (empty($userinfo) || $userinfo['expire_time'] < time()) {
                $userinfo = false;
            }
            return $userinfo;
        }
    }
}